package com.wan37.logic.skill;

import com.wan37.logic.domain.vo.AllRoleVO;
import com.wan37.logic.domain.vo.MonsterVO;
import com.wan37.logic.domain.vo.RoleVO;
import com.wan37.logic.domain.vo.SkillVO;
import com.wan37.logic.service.cache.RoleServiceCache;
import com.wan37.logic.service.cache.SceneServiceCache;
import com.wan37.logic.service.cache.UserServiceCache;
import com.wan37.logic.utils.DelayDequeThreadPollUtil;
import com.wan37.logic.utils.RouteUtils;
import com.wan37.protobuf.constant.AllRoleLabel;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author : luoyong
 * @date : 2020-06-24 15:50
 **/

public abstract class AbstractEnemyAOESkill implements BaseAOESkill {
    @Autowired
    protected UserServiceCache userServiceCache;
    @Autowired
    protected SceneServiceCache sceneServiceCache;
    @Autowired
    protected RoleServiceCache roleServiceCache;
    @Autowired
    protected DelayDequeThreadPollUtil delayDequeThreadPollUtil;
    @Autowired
    protected RouteUtils routeUtils;
    protected SkillVO skillVO;
    protected AllRoleVO allRoleVO;
    protected AllRoleVO allRoleVO2;
    protected volatile List<AllRoleVO> allRoleVOList;

    @Override
    public Map<String, Map<String, Long>> execute(SkillVO skillVO, AllRoleVO allRoleVO, List<AllRoleVO> allRoleVOList) {

        this.skillVO = skillVO;
        this.allRoleVO = allRoleVO;
        this.allRoleVOList = allRoleVOList;
        Map<String, Map<String, Long>> allRoleVONumberMap = null;
        if (allRoleVO.getLabel() == AllRoleLabel.MONSTER) {
            String sceneId = ((MonsterVO) allRoleVO).getSceneId();
            allRoleVONumberMap = handle(sceneId);
        } else if (allRoleVO.getLabel() == AllRoleLabel.ROLE) {
            String sceneId = userServiceCache.getUserServiceMap().get(((RoleVO) allRoleVO).getUserId()).getSceneId();
            allRoleVONumberMap = handle(sceneId);
        }
        return allRoleVONumberMap;
    }
}
